package com.springboot.service.impl;


import com.springboot.mapper.OrderFormMapper;
import com.springboot.mapper.PatientInfoFormMapper;
import com.springboot.mapper.UserLoginFormMapper;
import com.springboot.model.OrderForm;
import com.springboot.model.PatientInfoForm;
import com.springboot.model.UserLoginForm;
import com.springboot.service.DoctorMakePrescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 医生开药单
 */
@Service
public class DoctorMakePrescriptionServiceImpl implements DoctorMakePrescriptionService {
    @Autowired
    private UserLoginFormMapper userLoginFormMapper;

    @Autowired
    private OrderFormMapper orderFormMapper;

    @Autowired
    private PatientInfoFormMapper patientInfoFormMapper;

    //通过用户电话查找用户
    @Override
    public UserLoginForm findUserByTel(String tel)
    {
        UserLoginForm userLoginForm=userLoginFormMapper.selectByTel(tel);
        return userLoginForm;
    }

    //通过四个外键查找预约记录
    @Override
    public OrderForm findBookByForeign(OrderForm orderForm)
    {
        OrderForm order=orderFormMapper.selectByForeignKey(orderForm);
        return order;
    }

    //通过预约id查找预约就诊患者详情
    @Override
    public PatientInfoForm findPatientBybookId(Integer bookId)
    {
        PatientInfoForm patientInfo=patientInfoFormMapper.selectByPrimaryKey(bookId);
        return patientInfo;
    }

    //更新患者详情表的数据
    @Override
    public int updatePatientInfo(PatientInfoForm patientInfoForm)
    {
        return patientInfoFormMapper.updateByPrimaryKeySelective(patientInfoForm);
    }

    //更新预约表的数据
    @Override
    public int updateOrderForm(OrderForm orderForm)
    {
        return orderFormMapper.updateByPrimaryKeySelective(orderForm);
    }
}
